package com.aspirecn.gateway.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chenyuanli
 */
@Configuration
@EnableConfigurationProperties( { ZuulProperties.class } )
public class ZuulConfig {

	@Autowired
	ZuulProperties zuulProperties;
	@Autowired
	ServerProperties server;

	@Bean
	public RouteLocator routeLocator() {
		ApplicationRouteLocator routeLocator = new ApplicationRouteLocator(this.server.getServletPrefix(), this.zuulProperties);
		return routeLocator;
	}

}
